3 function wfSpecialRecentchanges( $par )
5 global $wgUser, $wgOut, $wgLang, $wgTitle;
6 global $days, $hideminor, $from, $hidebots; # From query string
7 $fname = "wfSpecialRecentchanges";
10 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
11 if( in_array( "hidebots", $bits ) ) $hidebots = 1;
12 if( in_array( "bots", $bits ) ) $hidebots = 0;
13 if( in_array( "hideminor", $bits ) ) $hideminor = 1;
14 if( in_array( "minor", $bits ) ) $hideminor = 0;
17 $sql = "SELECT MAX(rc_timestamp) AS lastmod FROM recentchanges";
18 $res = wfQuery( $sql, DB_READ
, $fname );
19 $s = wfFetchObject( $res );
20 if( $wgOut->checkLastModified( $s->lastmod
) ){
21 # Client cache fresh and headers sent, nothing more to do.
25 $rctext = wfMsg( "recentchangestext" );
27 # The next few lines can probably be commented out now that wfMsg can get text from the DB
28 $sql = "SELECT cur_text FROM cur WHERE cur_namespace=4 AND cur_title='Recentchanges'";
29 $res = wfQuery( $sql, DB_READ
, $fname );
30 if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text
!= "" ) ) {
31 $rctext = $s->cur_text
;
34 $wgOut->addWikiText( $rctext );
37 $days = $wgUser->getOption( "rcdays" );
38 if ( ! $days ) { $days = 3; }
41 list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
42 $now = wfTimestampNow();
43 $cutoff = wfUnix2Timestamp( time() - ( $days * 86400 ) );
44 if(preg_match('/^[0-9]{14}$/', $from) and $from > $cutoff) {
50 $sk = $wgUser->getSkin();
52 if ( ! isset( $hideminor ) ) {
53 $hideminor = $wgUser->getOption( "hideminor" );
55 $hideminor = ($hideminor ?
1 : 0);
57 $hidem = "AND rc_minor=0";
58 $mltitle = wfMsg( "show" );
62 $mltitle = wfMsg( "hide" );
66 if ( isset( $from ) ) {
67 $mlparams = "from={$from}&hideminor={$mlhide}";
69 $mlparams = "days={$days}&limit={$limit}&hideminor={$mlhide}";
72 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
73 $mltitle, $mlparams );
75 if ( !isset( $hidebots ) ) {
79 $hidem .= " AND rc_bot=0";
82 $uid = $wgUser->getID();
83 $sql2 = "SELECT recentchanges.*" . ($uid ?
",wl_user" : "") . " FROM recentchanges " .
84 ($uid ?
"LEFT OUTER JOIN watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace & 65534 " : "") .
85 "WHERE rc_timestamp > '{$cutoff}' {$hidem} " .
86 "ORDER BY rc_timestamp DESC LIMIT {$limit}";
87 $res = wfQuery( $sql2, DB_READ
, $fname );
90 $note = wfMsg( "rcnotefrom", $limit,
91 $wgLang->timeanddate( $from, true ) );
93 $note = wfMsg( "rcnote", $limit, $days );
95 $wgOut->addHTML( "\n<hr>\n{$note}\n<br>" );
97 $note = rcDayLimitLinks( $days, $limit, "Recentchanges", "hideminor={$hideminor}", false, $mlink );
99 $note .= "<br>\n" . wfMsg( "rclistfrom",
100 $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
101 $wgLang->timeanddate( $now, true ), "hideminor={$hideminor}&from=$now" ) );
103 $wgOut->addHTML( "{$note}\n" );
105 $count1 = wfNumRows( $res );
106 $obj1 = wfFetchObject( $res );
108 $s = $sk->beginRecentChangesList();
110 if ( ( 0 == $count1 ) ) {
113 if ( ! ( $hideminor && $obj1->rc_minor
) ) {
114 $rc = RecentChange
::newFromRow( $obj1 );
115 $s .= $sk->recentChangesLine( $rc, $obj1->wl_user
);
118 $obj1 = wfFetchObject( $res );
121 $s .= $sk->endRecentChangesList();
123 wfFreeResult( $res );
124 $wgOut->addHTML( $s );
127 function rcCountLink( $lim, $d, $page="Recentchanges", $more="" )
129 global $wgUser, $wgLang;
130 $sk = $wgUser->getSkin();
131 $s = $sk->makeKnownLink( $wgLang->specialPage( $page ),
132 ($lim ?
"{$lim}" : wfMsg( "all" ) ), "{$more}" .
133 ($d ?
"days={$d}&" : "") . "limit={$lim}" );
137 function rcDaysLink( $lim, $d, $page="Recentchanges", $more="" )
139 global $wgUser, $wgLang;
140 $sk = $wgUser->getSkin();
141 $s = $sk->makeKnownLink( $wgLang->specialPage( $page ),
142 ($d ?
"{$d}" : wfMsg( "all" ) ), "{$more}days={$d}" .
143 ($lim ?
"&limit={$lim}" : "") );
147 function rcDayLimitLinks( $days, $limit, $page="Recentchanges", $more="", $doall = false, $mlink = "" )
149 if ($more != "") $more .= "&";
150 $cl = rcCountLink( 50, $days, $page, $more ) . " | " .
151 rcCountLink( 100, $days, $page, $more ) . " | " .
152 rcCountLink( 250, $days, $page, $more ) . " | " .
153 rcCountLink( 500, $days, $page, $more ) .
154 ( $doall ?
( " | " . rcCountLink( 0, $days, $page, $more ) ) : "" );
155 $dl = rcDaysLink( $limit, 1, $page, $more ) . " | " .
156 rcDaysLink( $limit, 3, $page, $more ) . " | " .
157 rcDaysLink( $limit, 7, $page, $more ) . " | " .
158 rcDaysLink( $limit, 14, $page, $more ) . " | " .
159 rcDaysLink( $limit, 30, $page, $more ) .
160 ( $doall ?
( " | " . rcDaysLink( $limit, 0, $page, $more ) ) : "" );
161 $shm = wfMsg( "showhideminor", $mlink );
162 $note = wfMsg( "rclinks", $cl, $dl, $shm );
166 function rcLimitLinks( $page="Recentchanges", $more="", $doall = false )
168 if ($more != "") $more .= "&";
169 $cl = rcCountLink( 50, 0, $page, $more ) . " | " .
170 rcCountLink( 100, 0, $page, $more ) . " | " .
171 rcCountLink( 250, 0, $page, $more ) . " | " .
172 rcCountLink( 500, 0, $page, $more ) .
173 ( $doall ?
( " | " . rcCountLink( 0, $days, $page, $more ) ) : "" );
174 $note = wfMsg( "rclinks", $cl, "", $mlink );